function ReaderDetailView(params){
	var win = Ti.UI.createWindow({
		title: params.title,
		backgroundColor: "#FFF"
	});
	
	var file = Ti.Filesystem.getFile('xml/reading.xml');
	var contents = file.read();
	var xmltext = Ti.XML.parseString(contents.text);
	
	if ( file.exists() ) {
		var ReadingChapters = [];
		var readerDetailView = Titanium.UI.createTableView({
			top: 0,
			height: Ti.UI.FILL,
			backgroundColor: "transparent",
	    	data: ReadingChapters
		});
		
		var book = xmltext.documentElement.getElementsByTagName('chapter');
				
		for (var i=0; i<book.length; i++) {

			var chapterTitle = book.item(i).getElementsByTagName('chapternumber').item(0).textContent;
			
			if (chapterTitle == params.title){
				
				var sections = book.item(i).getElementsByTagName('section');

				for (var x=0; x<sections.length; x++){
					
					var sectionNumber = sections.item(x).getElementsByTagName('sectionnumber').item(0).textContent + '\n';
					var sectionText = sections.item(x).getElementsByTagName('text').item(0).textContent + '\n';
					
					if (x==0){
						var textDisplay = sectionNumber + sectionText;
					} 
					else {
						textDisplay = textDisplay + '\n' + sectionNumber + sectionText;	
					}
				}
			
				var chapterTextLabel = Ti.UI.createLabel({
					text: textDisplay,
					font: {
						fontSize: "12dp",
						fontFamily: (Ti.Platform.osname === "android") ? "Aller_Bd" : "Aller",
						fontWeight: "bold" //Android will ignore this
					},
					top: "10dp",
					left: "5dp",
					textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
					color: "#000"
				});
				
				win.add(chapterTextLabel);
			}			
		}	
	}
	
	return win;
}

module.exports = ReaderDetailView;